<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function check1(){
				let reg=/^[A-z]\w{2,14}$/
				let username=document.getElementById("username").value
				if(reg.test(username)){
					document.getElementById("r1").innerHTML="OK"
				}else{
					document.getElementById("r1").innerHTML="error"
				}
			}
			function check2(){//1已经占用了一位
				let reg=/^1\d{10}$/
				let phone=document.getElementById("phonenum").value
				if(reg.test(phone)){
					document.getElementById("r2").innerHTML="OK"
				}else{
					document.getElementById("r2").innerHTML="error"
				}
			}
			function check3(){//添加问号,表示前面的词可以不存在
				let reg=/(^0\d{2}-?\d{8}$)|(^0\d{3}-?\d{7}$)/
				let tel=document.getElementById("telnum").value
				if(reg.test(tel)){
					document.getElementById("r3").innerHTML="OK"
				}else{
					document.getElementById("r3").innerHTML="error"
				}
			}
			function check4(){//(整数)(\.小数)
				let reg=/^(0|([1-9]\d{0,14}))(\.\d{1,2})?$/
				let money=document.getElementById("money").value
				if(reg.test(money)){
					document.getElementById("r4").innerHTML="OK"
				}else{
					document.getElementById("r4").innerHTML="error"
				}
			}
			
			
			
		</script>
	</head>
	<body>
		输入用户名称：<input type="text" id="username" />
		<button type="button" onclick="check1()">检测</button>
		<span id="r1"></span><br >
		输入手机号码：<input type="text" id="phonenum" />
		<button type="button" onclick="check2()">检测</button>
		<span id="r2"></span><br >
		输入座机号码：<input type="text" id="telnum" />
		<button type="button" onclick="check3()">检测</button>
		<span id="r3"></span><br >
		输入存款金额：<input type="text" id="money" />
		<button type="button" onclick="check4()">检测</button>
		<span id="r4"></span><br >
	
	
	</body>
</html>
